package five_class_design_creational_patterns.one_abstractFactory;


import org.w3c.dom.*;
import org.xml.sax.SAXException;
import javax.xml.parsers.*;
import java.io.File;

public class XMLUtil
{
	public static Object getBean()
	{
		try
		{
			DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
			DocumentBuilder builder = dFactory.newDocumentBuilder();
			Document doc;
			doc = builder.parse(new File("G:\\SringBoot_Cloud\\Software_design\\src\\five_class_design_creational_patterns\\one_abstractFactory\\abstractFactoryConfig.xml"));
//			doc = builder.parse(new File("../../../abstractFactoryConfig.xml"));
		
			NodeList nl = doc.getElementsByTagName("className");
            Node classNode=nl.item(0).getFirstChild();
            String cName=classNode.getNodeValue();
            
            Class c=Class.forName("five_class_design_creational_patterns.one_abstractFactory."+cName);
	  	    Object obj=c.newInstance();
            return obj;
           }   
           	catch(Exception e)
           	{
           		e.printStackTrace();
           		return null;
           	}
		}
}
